//引入axios请求
import request from '@/utils/request';

//1.商品列表请求

//商品请求返回值类型限制
export interface ProductReturnType extends AddProductType{
    id : number;
}
//商品请求传参类型限制
export interface productListType {
    page: number;
    limit: number;
}

export type TrademarkListItemType = ProductReturnType[]

//商品请求返回值类型限制
export interface TrademarkListReturnType {
    records: TrademarkListItemType;
    total: number;
    size: number;
    current: number;
    searchCount: boolean;
    pages: number;
}

//商品列表请求函数
export const getProductListRequest = ({page,limit} : productListType) => {
    return request.get<any,TrademarkListReturnType>(`/admin/product/baseTrademark/${page}/${limit}`)
}

//2.修改商品请求

//修改商品请求函数
export const getReviseProductRequest = (putParams : ProductReturnType) => {
    return request.put<any,null>(`/admin/product/baseTrademark/update`,putParams)
}

//3.删除商品请求

//删除商品请求函数
export const getDeleteProductRequest = (id:number) => {
    return request.delete<any,null>(`/admin/product/baseTrademark/remove/${id}`)
}

//4.新增商品请求

//新增商品请求参数类型限制
export interface AddProductType {
    tmName : string;
    logoUrl :string
}

//新增商品请求函数
export const getAddProductRequest = (addParams : AddProductType) => {
    return request.post<any,null>(`/admin/product/baseTrademark/save`,addParams)
}

//获取所有品牌请求

export interface getAllTmListType {
    id:number,
    tmName:string,
    logoUrl:string
}
export const getAllTmList = () => {
    return request.get<any,getAllTmListType[]>(`/admin/product/baseTrademark/getTrademarkList`)
}

